package com.study;

import com.study.bean.CartoonCatAndMouse;
import com.study.bean.CartoonProperties;
import com.study.bean.Fish;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.*;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Indexed;

/**
 * @desc:
 * @author: panxiyi
 * @date: 2023/5/20 10:00 下午
 */

//@SpringBootConfiguration
//    @Configuration
//        @Component
//    @Indexed
//@EnableAutoConfiguration
//    @AutoConfigurationPackage
//        @Import({AutoConfigurationPackages.Registrar.class})
//    @Import({AutoConfigurationImportSelector.class})
//@ComponentScan

// 所以只需要关注以下两个
//@Import({AutoConfigurationPackages.Registrar.class})   设置当前配置所在的包作为扫描包，后续要针对当前的包进行扫描
//@Import({AutoConfigurationImportSelector.class})

@SpringBootApplication(excludeName = "org.springframework.boot.autoconfigure.context.LifecycleAutoConfiguration")
//@Import(CartoonCatAndMouse.class)
public class App {
    public static void main(String[] args) {
        ConfigurableApplicationContext ctx = SpringApplication.run(App.class);
        CartoonCatAndMouse bean = ctx.getBean(CartoonCatAndMouse.class);
        bean.play();
//        String[] beanDefinitionNames = ctx.getBeanDefinitionNames();
//        for (String beanDefinitionName : beanDefinitionNames) {
//            System.out.println(beanDefinitionName);
//        }
//
//        CartoonProperties cartoonProperties = ctx.getBean(CartoonProperties.class);
//        System.out.println(cartoonProperties.getMouse().toString());
        Fish bean1 = ctx.getBean(Fish.class);
        System.out.println(bean1);
    }
}
